from django.db import models

# Create your models here.
# 作者名	性别	年龄
class Author(models.Model):
    authorname = models.CharField(max_length=10)
    gender = models.CharField(max_length=6)
    age = models.IntegerField()

# 书名	价格	出版日期	类别	外键
class Book(models.Model):
    bookname = models.CharField(max_length=10)
    price = models.FloatField()
    publishtime = models.DateField()
    kind = models.CharField(max_length=10)
    authorid = models.ForeignKey("Author")
    # self.pk
    # 定义
    def __str__(self):
        return "图书名-"+str(self.bookname)

class StudentInfo(models.Model):
    # 学号
    num = models.CharField(max_length=20)
    # 姓名
    name = models.CharField(max_length=10)
    # 性别
    gender = models.CharField(max_length=5)
    def __str__(self):
        return "姓名:"+str(self.name)
    class Meta:
        ordering = ["num"]